package com.heo.protocol.packet;

import org.apache.log4j.Logger;

import com.heo.pub.DictEnum;
import com.heo.util.ByteHelper;

public class GetDeviceParaResp extends BasePacket
{
  private int BODY_LENGTH = 8;// 包体长8个字节

  private static final String PACKET_NAME = "[获取设备参数应答包]";
  private static Logger log = Logger.getLogger(GetDeviceParaResp.class);
  
  private byte heartInterval = 0x3C;//心跳间隔 ,默认60秒
  private byte deviceTimeOut = 0x78;//设备超时时间，120秒，120秒没有任何数据
  private byte answerTimeOut = 0x03;//接收应答的超时时间
  private byte retryCount = 0x03;//重试次数
  private byte socketMode = DictEnum.SocketMode.LONG;//长连接
  private byte reSendMode = DictEnum.ReSend.YES;
  private byte pulseType = 0x01;//脉冲类型
  private byte startLevel = 0x01;//启动电平

  public GetDeviceParaResp(short sequenceId) throws Exception
  {
    super(PACKET_NAME);
    super.totalLength = (short) (HEAD_LENGTH + BODY_LENGTH);
    super.commandId = DeviceCommand.GET_DEVICE_PARA_RESP;
    super.sequenceId = sequenceId;
  }
  
  @Override
  public int getTotalLength()
  {
    return super.HEAD_LENGTH + BODY_LENGTH;
  }

  @Override
  public byte[] getPacketBody()
  {
    return ByteHelper.margeByte(new byte[]{heartInterval}, new byte[]{deviceTimeOut}, new byte[]{answerTimeOut}, new byte[]{retryCount}, new byte[]{socketMode}, new byte[]{reSendMode},  new byte[]{pulseType},  new byte[]{startLevel}, null, null);
  }

  public static void main(String[] args)
  {

  }

  @Override
  public void makeBody()
  {

  }

  public byte getHeartInterval()
  {
    return heartInterval;
  }

  public void setHeartInterval(byte heartInterval)
  {
    this.heartInterval = heartInterval;
  }

  public byte getAnswerTimeOut()
  {
    return answerTimeOut;
  }

  public void setAnswerTimeOut(byte answerTimeOut)
  {
    this.answerTimeOut = answerTimeOut;
  }

  public byte getRetryCount()
  {
    return retryCount;
  }

  public void setRetryCount(byte retryCount)
  {
    this.retryCount = retryCount;
  }

  public byte getSocketMode()
  {
    return socketMode;
  }

  public void setSocketMode(byte socketMode)
  {
    this.socketMode = socketMode;
  }

  public byte getReSendMode()
  {
    return reSendMode;
  }

  public void setReSendMode(byte reSendMode)
  {
    this.reSendMode = reSendMode;
  }

  public byte getDeviceTimeOut()
  {
    return deviceTimeOut;
  }

  public void setDeviceTimeOut(byte deviceTimeOut)
  {
    this.deviceTimeOut = deviceTimeOut;
  }

  public byte getPulseType()
  {
    return pulseType;
  }

  public void setPulseType(byte pulseType)
  {
    this.pulseType = pulseType;
  }

  public byte getStartLevel()
  {
    return startLevel;
  }

  public void setStartLevel(byte startLevel)
  {
    this.startLevel = startLevel;
  }

}
